<?php
/**
 * @var $this Pinenut\Action
 * @var $profile \Users\Profile
 * @var $groupId string
 * @var $companionProfileId string
 * @var companionProfileIsServiceType bool
 */

/** @var \Messenger\Groups $groupModel */
$groupModel = \Messenger\Groups::find($groupId);
$isBlocked = $groupModel->hasRelation((string)$profile, \Messenger\Relations::STATUS_BLOCKED);

# TODO: убрать этот говнокод
$noAvatarDefaultImg = '/img/no-avatar-big.jpg';
$noAvatar = !$profile->getAvatar()->_id;

if ($noAvatar) {
    $avatarSrc = $noAvatarDefaultImg;
} else {
    $avatarSrc = $this->url('photos.thumb', ['id' => $profile->getAvatar()->_id, 'thumb' => 'messenger']);
}
?>
<div class="md-footer">
	<?php if (!$companionProfileIsServiceType) : ?>
    <div class="md-new-message">
        <div class="md-input-wrapper">
            <img class="md-iw-avatar" alt="" src="<?php echo $avatarSrc; ?>">
            <div class="md-iw-input">
                <?php echo $this->action(
                    '.form',
                    [
                        'groupId' => $groupId,
                        'myProfileId' => (string)$profile,
                        'companionProfileId' => $companionProfileId,
                    ]
                ); ?>
                <!-- <div class="md-iw-smile-btn"></div> -->
            </div>
        </div>
        <div class="md-send-btn-wrapper clearfix">
			<input id="messenger-message-send-button" type="submit" value="Send" class="btn btn-common">

            <a id="messenger-messages-area-delete" targetProfileId="<?php echo $companionProfileId; ?>" newRelationStatus="<?php echo \Messenger\Relations::STATUS_UNKNOWN?>" class="md-delete-user md-user-control" href="#">delete this user</a>
            <a id="messenger-messages-area-blocked" targetProfileId="<?php echo $companionProfileId; ?>" newRelationStatus="<?php echo $isBlocked ? \Messenger\Relations::STATUS_NEUTRAL : \Messenger\Relations::STATUS_BLOCKED; ?>" class="md-user-control <?php echo $isBlocked ? 'md-remove-ignore-user' : 'md-ignore-user'; ?>" href="#"><?php echo $isBlocked ? 'Unignore this user' : 'Ignore this user'; ?></a>
        </div>
    </div>
	<?php endif; ?>
</div>

